package com.hnevc.acountms.dao;

import com.hnevc.acountms.model.Tb_outaccount;

import org.litepal.crud.DataSupport;

import java.util.List;

/**
 * Created by Administrator on 2017/9/27.
 */

public class OutacountDao {
    public void add(Tb_outaccount outacount){
        outacount.save();
    }
    public void update(Tb_outaccount outacount){
        outacount.save();
    }
    public Tb_outaccount find(int id){
        List<Tb_outaccount> outacounts= DataSupport.where("_id=?",id+"")
                .find(Tb_outaccount.class);
        if(outacounts.size()>0){
            return outacounts.get(0);
        }else{
            return null;
        }

    }
    public void delete(int... ids){
        for(int i=0;i<ids.length;i++) {
            DataSupport.deleteAll(Tb_outaccount.class, "id=?", ids[i]+"");
        }
    }
    public List<Tb_outaccount> getScrollData(int start, int count){
        List<Tb_outaccount> outacounts = DataSupport.limit(count)
                .offset(start)
                .find(Tb_outaccount.class);
        return outacounts;

    }
    public long getCount(){
        int count = DataSupport.count(Tb_outaccount.class);
        return count;
    }
    public int getMaxId(){
        int id = DataSupport.max(Tb_outaccount.class, "id", int.class);
        return id;

    }
}
